
package at.fhj.itm.metadata.impl.postgres;

import at.fhj.itm.metadata.impl.AbstractIndex;
import java.util.List;
import static at.fhj.itm.metadata.MetadataUtil.copyMetadataList;
/**
 *
 * @author Seuchter
 */
public class PostgresIndex extends AbstractIndex
{

    private boolean isClustered;
    private String accessMethod;
    private List<PostgresColumn> columns;
    private PostgresTable table;
    public PostgresIndex(String name, boolean isPrimary, boolean isUnique, boolean isClustered,
            String accessMethod, List<PostgresColumn> cols, PostgresTable table)
    {
        super(name,isPrimary, isUnique);
        this.columns = cols;
        this.accessMethod = accessMethod;
        this.isClustered = isClustered;
        this.table = table;
    }
    public PostgresTable getTable()
    {
        return table;
    }
    public String getAccessMethod()
    {
        return accessMethod;
    }

    public boolean isClustered()
    {
        return isClustered;
    }

    public List<PostgresColumn> getColumns()
    {
        return columns;
    }

    @Override
    public String toString() {
    	// XXX fix velocity template so that getName is used instead of toString
    	return getName();
    }
    public PostgresIndex copy(){
        return new PostgresIndex(getName(), isPrimaryKey(), isUnique(), isClustered(), getAccessMethod(),
                copyMetadataList(getColumns()), getTable());
    }
}

